import fetch from '@/utils/fetch'

var qs = require('qs')

export function queryPage(data) {
  return fetch({
    url: '/user/queryPage',
    method: 'post',
    data
  })
}

export function create(data) {
  return fetch({
    url: '/user/create',
    method: 'post',
    data
  })
}

export function update(data) {
  return fetch({
    url: '/user/update',
    method: 'post',
    data
  })
}

export function deleted(data) {
  return fetch({
    url: '/user/delete',
    method: 'post',
    data
  })
}

export function allRole() {
  return fetch({
    url: '/role/all',
    method: 'get'
  })
}

export function ownRole(userId) {
  return fetch({
    url: '/user/ownRole',
    method: 'get',
    params: { userId }
  })
}

export function getUserNameById(userId) {
  return fetch({
    url: '/user/getUserNameById',
    method: 'get',
    params: { userId }

  })
}

export function getUserNameByIds(idList) {
  return fetch({
    url: '/user/getUserNameByIds',
    method: 'post',
    data: JSON.stringify([1, 2, 3]),
    headers: { 'Content-Type': 'application/json;charset=UTF-8' }
  })
}

export function grantRole(userId, roleIds) {
  const data = {
    userId,
    roleIds
  }
  return fetch({
    url: '/user/grantRole',
    method: 'post',
    data
  })
}

export function GetUserDepartment(name) {
  return fetch({
    url:'/user/getUserDepartment',
    method:'get',
    params:{name}
  })
}

export function GetRolesById(id) {
  return fetch({
    url:'/user/getRolesById',
    method:'get',
    params:{id}
  })
}

export function GetOrgDep() {
  return fetch({
    url:'/user/getOrgDep',
    method:'get'
  })
}

export function GetUserLikeAccount(account) {
  return fetch({
    url:'/user/getUserLikeAccount',
    method:'get',
    params:{account}
  })
}

export function GetUserLikeName(name) {
  return fetch({
    url:'/user/getUserLikeName',
    method:'get',
    params:{name}
  })
}

export function GetUserLikeMobile(mobile) {
  return fetch({
    url:'/user/getUserLikeMobile',
    method:'get',
    params:{mobile}
  })
}

